#!/usr/bin/python

from importlib import import_module
from .base import LocalStorage
from . import minio_oss
# from . import tencent_oss
# from . import ali_oss
# from . import huawei_oss

__storages = {
    "local": LocalStorage,
    # "AliYun": ali_oss.AliOss,
    # "tencent": tencent_oss.CosOss,
    "minio": minio_oss.MinioOss,
}


def get_storage(ttype=None):
    if ttype is None:
        return LocalStorage()
    return __storages.get(ttype)


if __name__ == '__main__':
    ttype = "tencent"

    config = {"key_id": "AKIDwf*****Hfma7NLLIzPFtH",
              "secret": "B5h38vQdZ******x5wXr",
              "bucket": "szhss-1******947",  # 桶名
              "region": "ap-nanjing",
              "host": "cos.ap-nanjing.myqcloud.com"
              }
    oss = get_storage(ttype)(**config)
    # print(oss.list_dir_files("hss"))
    path = '寒山寺hhh.xls'

    with open("./aaaa.xls", 'rb') as f:
        oss.upload(path, f)

    print(oss.download_url(path))
